<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('牛奶入库列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="btn-group " style="margin: 0px auto;display: table;" role="group">
                <button type="button" class="top-link btn btn-sm btn-white ">农事</button>
                <button type="button" class="top-link btn-sm  btn-white">牛奶入库</button>
                <button type="button" class="top-link btn-sm  btn-primary">牛奶仓储</button>
                <button type="button" class="top-link btn-sm btn-white">牛奶出库</button>
            </div>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
    <div class="bottom-btns"></div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncInputMilk:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncInputMilk:remove')}]];
    var prefix = ctx + "system/ncInputMilkStorage";

    $(function () {
        var options = {
            url: prefix + "/list?stock=1",
            createUrl: ctx + "system/ncOrderCf" + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "牛奶入库",
            showExport: true,
            sortName:'inputTime',
            sortOrder:'desc',
            showFooter: true,
            columns: [
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    },
                    footerFormatter: function () {
                        return '合计'
                    }
                },
                {
                    field: 'inputCode',
                    title: '牛奶批次',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                /*{
                    field: 'inputAmout',
                    title: '入库数量（kg）',
                    sortable: true
                },*/
                {
                    field: 'leftAmout',
                    title: '库存(kg)',
                    sortable: true,
                    footerFormatter: function () {
                        //统计总分数
                        var count = 0;
                        $.each($('#bootstrap-table').bootstrapTable('getData'), function (index, item) {
                            count += item.leftAmout;
                        });
                        return count;

                    }
                },
                /*{
                    field : 'leftAmout',
                    title : '剩余量',
                    sortable: true
                },
                {
                    field : 'bottleAmount',
                    title : '瓶数',
                    sortable: true
                },*/
                {
                    field : 'milkmanName',
                    title : '挤奶人员',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field : 'disinfectorName',
                    title : '消毒人员',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                {
                    field: 'inputTime',
                    title: '入库时间',
                    sortable: true,
                    footerFormatter: function () {
                        return '-'
                    }
                },
                /*{
                    field : 'inputType',
                    title : '入库类型 ：字典',
                    sortable: true
                },*/
                {
                    field : 'inputUserName',
                    title : '入库经手人',
                    footerFormatter: function () {
                        return '-'
                    }
                },
                /*{
                    field : 'createBy',
                    title : '创建者',
                    sortable: true
                },
                {
                    field : 'createTime',
                    title : '创建时间',
                    sortable: true
                },*/
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        /*actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.inputId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.inputId + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        actions.push('&nbsp;<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="depot(\'' + row.inputId + '\')"><i class="fa fa-key"></i>出库</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
        var btns = [
            {
                name: "产奶记录",
                url: ctx + 'system/ncCowsMilk',
                id: 'Milk-work'
            },
            {
                name: "主饲料",
                url: ctx + 'system/ncFeed?feedType=1',
                id: 'Feed-work'
            },
            {
                name: "辅饲料",
                url: ctx + 'system/ncFeed2?feedType=2',
                id: 'Feed2-work'
            },
            {
                name: "消毒记录",
                url: ctx + 'system/ncCowsDisinfection?managerType=2',
                id: 'Disinfection-work'
            },
            {
                name: "兽医请求",
                url: ctx + 'system/ncZhenliaoLogs/cow/askZhenLiaoList ',
                id: 'Zhenliao-work'
            },
            {
                name: "所有诊疗记录",
                url: ctx + 'system/ncZhenliaoLogs/cow/allZhenliao   ',
                id: 'Zhenliao-all'
            },
            {
                name: "诊疗单",
                url: ctx + 'system/ncOrder?orderType=14',
                id: 'Medical-work'
            },
            {
                name: "档案管理",
                url: ctx + 'system/ncCowsFiles',
                id: 'Depot-work'
            },
            {
                name: '工作记录',
                url: ctx + 'system/ncNormalWorks?workType=8',
                id: 'normal-work'
            },
            {
                name: '所有出库',
                url: ctx + 'system/ncOutputMilk/ncOutputMilkAll',
                id: 'ncOutputMilkAll'
            }

        ]
        addBtns(btns);
    });

    /*牛奶入库*/
    $('.top-link').click(function () {
        var index = $(this).index();
        switch (index) {
            case 0:
                window.location.href = ctx + 'system/ncWorkNotice';
                return;
            case 1:
                window.location.href = ctx + 'system/ncInputMilk';
                return;
            case 2:
                window.location.reload();
                return;
            case 3:
                window.location.href = ctx + 'system/ncOutputMilk';
                return;
        }
    })

    /*表单确认*/
    function confirmTable() {
        var confirmTable = prefix + "/confirmTable";
        var data = $('#bootstrap-table').bootstrapTable('getData');
        if (data && data.length > 0) {

            $.modal.confirm("确认生成订单吗？", function () {
                var ids = [];
                $(data).each(function (i, e) {
                    ids.push(e.inputId);
                });
                var ids_str = ids.join(",");
                myPost(confirmTable, {ids: ids_str},
                    function (data) {

                        if (data.code == 0) {
                            layer.msg("提交成功")
                        } else {
                            layer.msg(data.msg);
                        }
                        reload()
                    }, function (e) {
                        layer.msg("确认失败!");
                        reload()
                    })

            })
        } else {
            layer.msg("未发现数据!")
        }

    }

    /*打开检测记录单*/
    function openOrder() {

        var url = ctx + 'system/ncOrder?orderType=10 ';

        $.modal.openTab("检测记录单", url);
    }

    function reload() {
        $.table.refresh();
    }


    /* 出库操作 */
    function depot(goodsId) {
        var url = prefix + '/depot/' + goodsId;
        $.modal.open("出库", url);
    }
    setTitle("牛舍管理-牛奶仓储",false)

</script>
</body>
</html>